package com.ourteam.product.requirement.api;

import org.apache.commons.lang.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.product.requirement.dao.ProductRoleRelateDAOQueryBean;
import com.ourteam.product.requirement.domain.ProductRoleRelateBean;

public class ProductRoleRelateSearchModel extends AbstractSearchModel<ProductRoleRelateDAOQueryBean> {

	private long productElementId;

	private String productElementType;

	@Override
	public String getMappedDAOField(String aProperty) {
		return ProductRoleRelateBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(ProductRoleRelateDAOQueryBean queryBean) throws Exception {

		ProductRoleRelateDAOQueryBean.Criteria criteria = queryBean.createCriteria();

		if (StringUtils.isNotBlank(productElementType)) {
			criteria.andProductElementTypeEqualTo(productElementType);
		}

		if (productElementId != 0) {
			criteria.andProductElementIdEqualTo(productElementId);
		}
	}

	public long getProductElementId() {
		return productElementId;
	}

	public void setProductElementId(long productElementId) {
		this.productElementId = productElementId;
	}

	public String getProductElementType() {
		return productElementType;
	}

	public void setProductElementType(String productElementType) {
		this.productElementType = productElementType;
	}

}
